package com.iot.ammeter.controller.user;


import com.iot.ammeter.anno.LogAnnotation;
import com.iot.ammeter.dto.web.menu.MenuDTO;
import com.iot.ammeter.responseResult.ResponseResult;
import com.iot.ammeter.service.web.menu.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * web端用户菜单导航 前端控制器
 * </p>
 *
 * @author basil
 * @since 2021-09-25
 */
@RestController
@Api(tags = {"菜单管理"})
@RequestMapping("/api/menu")
public class MenuController {

    private final MenuService menuService;

    public MenuController(MenuService menuService) {
        this.menuService = menuService;
    }

    /**
     * 获取菜单列表
     *
     * @return ResponseResult
     */
    @ApiOperation("获取菜单列表")
    @LogAnnotation(module = "getMenuList", operator = "获取菜单列表")
    @GetMapping("/list")
    public ResponseResult getMenuList() {
        List<MenuDTO> menuList = menuService.getMenuList();
        return menuList.size() > 0 ? ResponseResult.SUCCESS(menuList) : ResponseResult.FAILED("无数据");
    }
}
